<!--
  * 时间：2025/1/17
  * 作者：刘岩
  * 描述：报警系统 - 设备管理
-->
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item label="设备名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入设备名称"
          clearable
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="equipmentList">
<!--      <el-table-column type="selection" width="55" align="center" />-->
      <el-table-column label="设备名称" align="center" prop="cn" />
      <el-table-column label="所属区域" align="center" prop="regionName" />
      <el-table-column label="设备状态" align="center" prop="online">
        <template slot-scope="scope">
          <span>{{ scope.row.online === 0 ? '离线' : scope.row.online === 1 ? '在线' : '' }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getAlarmData } from "@/api/alarmSystem/device";

export default {
  name: "Device",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 设备表格数据
      equipmentList: [],
      // 查询参数
      queryParams: {
        name: null,
        pageNum: 1,
        pageSize: 10
      },
      // 展厅数据
      hallSearchOptions: []
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询设备列表 */
    getList() {
      this.loading = true;
      getAlarmData().then(res => {
        console.log(res)
        // let data = JSON.parse(res.msg);
        // this.equipmentList = data.data.list;
        // this.total = data.data.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    }
  }
}
</script>

<style scoped lang="scss">
.el-select--medium {
  width: 100%;
}
</style>
